This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Mar 15, 2011, 5:47 PM
8 Posts

is xp:dominoView a type of dataContext?

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 8.5.1
  • Role: Developer
  • Tags: dataContext
  • Replies: 2
I have a repeat control to which I need to pass a document collection or the dominoView depending on a condition. The document collection  is computed as a dataContext (following).
 

      <xp:this.dataContexts>

            <xp:dataContext var="dcSearchResults">

                  <xp:this.value><![CDATA[#{javascript:var db:NotesDatabase=session.getDatabase("","")

db.openByReplicaID(sServerName, sReplicaID );

var vw=db.getView("view1");

var dc=vw.getAllDocumentsByKey("key1");

return dc;

}]]></xp:this.value>         

            </xp:dataContext>      

      </xp:this.dataContexts>



The dominoView is defined like the following.
 

      <xp:this.data>

            <xp:dominoView var="dominoView"

                  categoryFilter="#{javascript:compositeData.SingleCategory}"

                  databaseName="#{javascript:compositeData.Database}"

                  viewName="#{javascript:compositeData.ViewName}">

            </xp:dominoView>

      </xp:this.data>

 
 
 
 
 
 
 
 
 
 
 
Here is the repeat control code.

                  <xp:repeat var="ViewEntry" disableTheme="true"

                        id="rptViewBody"

                        rows="#{javascript:(compositeData.RowCount?compositeData.RowCount:20)}"

                        value="#{javascript:isSearchOn()!=true?dominoView:dcSearchResults}">

 
The dcSearchResults work just fine and the repeat control is displaying the rows correctly. But the dominoView shows no records. If the repeat control value is given as "#{javascript:dominoView}", then it displays the rows. So I think the dominoView cannot be mixed with other code and it should just be a simple "#{dominoView}" or "#{javascript:dominoView}".
 
I have the "Mastering the XPages.." book and it has just a brief introduction about the dataContexts. Can someone shed some light on this.
 
P.S: The code is simplified to make the question clear. So please do not worry about why I need to do it this way. The question is more on how the dominoView or a dataContext can be applied conditionally to a repeat control.
Mar 16, 2011, 10:30 PM
122 Posts
Re: is xp:dominoView a type of dataContext?
I think the problem you may be getting is the data type for each row in the repeat. For your dataContext, you're returning a collection of NotesDocuments. From the view, you're returning NotesXSPViewEntries. That could cause a problem.
 
I'm not sure if this will work, but what happens if you return a NotesViewEntry collection instead of a NotesDocumentCollection? 
 
As I say, it may not work, because they're still slightly different data types returned. But as they're more similar, it may work. 
Mar 17, 2011, 12:13 PM
8 Posts
Re: is xp:dominoView a type of dataContext?
Hi Paul,
 
Actually that's not the issue. While "#{dominoView}" or "#{javascript:dominoView}" is returning the collection (view entry collection), this variable (dominoView) if mixed with a little bit of more code, just returns the object lotus.domino.local.View (not a collection).
 
So I am not sure why the same variable returns the view entry collection in one case and the view object in the other case.

When it returns the collection, it is after applying all filters on the xp:dominoView data (like categoryFilter, keys etc.). But when it gives just the view object, I then have to do getAllEntriesByKey() to do what was otherwise given as a property of the xp:dominoView.
 
Hope I clarified the issue.

Thanks,
Rajeev.
 
 

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal